<template>
    <h1 style="line-height: 100px;">信息修改</h1>
    <el-input v-model="phone" placeholder="手机号" />
    <el-button type="success" @click="update">确认修改</el-button>
</template>

<script>
import { mapState } from 'vuex'
export default {
    data() {
        return {
            phone: ''
        }
    },
    computed: {
        ...mapState(['usersj'])
    },
    methods: {
        update() {

            //这个是写成对象的形式,如果写成对象的形式带的值num在index.js中也要写成playload.num
            // this.$store.commit({
            //     type:'updateUser',
            //     num:this.input
            // })

            const newuserInfo = { ...this.usersj, phone: this.phone }
            this.$store.commit('updateUser', newuserInfo)
            this.$router.push({ path: '/index' })
            console.log(this.phone);
            console.log(this.$store.state);
        }
    }
}
</script>